package com.example.newsdaily.slice;

import com.example.newsdaily.LoginAbility;
import com.example.newsdaily.LoginOrRegisterAbility;
import com.example.newsdaily.ResourceTable;
import com.example.newsdaily.utl.ContainUtil;
import com.example.newsdaily.utl.LocalDataUtil;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;
import ohos.data.preferences.Preferences;


public class StartAbilitySlice extends AbilitySlice {
    Preferences preferences= LocalDataUtil.preferences;
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_start);
        Boolean used=preferences.getBoolean(ContainUtil.USER_USED_KEY,false);
        if(!used){
            preferences.putBoolean(ContainUtil.USER_USED_KEY,true);
            Intent intent1=new Intent();
            Operation operation=new Intent.OperationBuilder()
                    .withBundleName(getBundleName())
                    .withAbilityName(LoginOrRegisterAbility.class)
                    .build();
            intent1.setOperation(operation);
            startAbility(intent1);
        }else{
            preferences.putBoolean(ContainUtil.USER_USED_KEY,true);
            Intent intent1=new Intent();
            Operation operation=new Intent.OperationBuilder()
                    .withBundleName(getBundleName())
                    .withAbilityName(LoginAbility.class)
                    .build();
            intent1.setOperation(operation);
            startAbility(intent1);
        }
    }

    @Override
    public void onActive() {
        super.onActive();
        int i;
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
